class: center, middle, inverse, title-slide .title[ # Lecture 18 ] .subtitle[ ## Simple Linear Regression ] .author[ ### Psych 10 C ] .institute[ ### University of California, Irvine ] .date[ ### 05/11/2022 ] --- ## Simple linear regression - Last class we mentioned that we can use a line in order to make predictions about the values of a continuous dependent variable when we have information about an independent variable. -- - We also mentioned that the equation of the line is defined by two parameters: -- - `\(\beta_0\)` which is known as the **intercept** and it can be interpreted as the expected value of the dependent variable when the independent variable is equal to 0. -- - `\(\beta_1\)` which is known as the **slope** which is the change in the expectation of our dependent variable for a **unit** increase in the value of our independent variable. -- - The problem was that each combination of values of `\(\beta_0\)` (**intercept**) and `\(\beta_1\)` (**slope**) will give us a different line, so we need a way to choose the best one. --- ## Least Squares - The method that we use to find the values of `\(\beta_0\)` and `\(\beta_1\)` is known as Least Squares. The idea is that we want to choose the values of the parameters that minimize the error of the predictions in the model. -- - In other words, we want to find the values that minimize the Sum of Squared Errors (SSE). .pull-left[ <img src="data:image/png;base64,#lec-18_files/figure-html/miss-grade-lm1-1.png" style="display: block; margin: auto;" /> ] .pull-right[ <img src="data:image/png;base64,#lec-18_files/figure-html/miss-grade-lm2-1.png" style="display: block; margin: auto;" /> ] --- ## Models for simple linear regression - Before we find the values of the parameters for the simple linear regression model, we want to formalize the models that we are going to compare. -- - Given that we have a single independent variable `\(x_i\)`, we will only need to compare two models in order for us to test whether the independent variable has an effect on our dependent variable. --- ## Null model - As with previous problems, in a simple linear regression we want to compare 2 different models. The first on these models is the Null. -- - The Null model in a simple linear regression formalizes the assumption that the expected value of our independent variable does not depend on the values of the independent variable. -- - This model is expressed formally as: `$$y_i \sim \text{Normal}(\beta_0, \sigma_0^2)$$` -- - This Null model is similar to the one we have used before, and it assumes that the expected value of our dependent variable `\(y\)` is the same regardless of the values of our independent variable `\(x_i\)`. -- - Let's look back to our example about predicting grades from the number of classes that a student missed during a quarter. --- ## Example: grades and classes missed - We want to know how the grade that a student gets (dependent variable) changes as a function of the number of classes they missed during the quarter (independent variable).